package com.lsa.letcode.the61.rotateList;

import static org.junit.Assert.*;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;
import com.lsa.letcode.common.ListNode;

public class RotateListTest extends LetCodeTestBase {
	@Test
	public void testName() throws Exception {
		Solution s = new Solution();
		test(s, asList(1, 2, 3, 4, 5), asList(1, 2, 3, 4, 5), 5);
		test(s, asList(2, 3, 4, 5, 1), asList(1, 2, 3, 4, 5), 4);
		test(s, asList(3, 4, 5, 1, 2), asList(1, 2, 3, 4, 5), 3);
		test(s, asList(4, 5, 1, 2, 3), asList(1, 2, 3, 4, 5), 2);
		test(s, asList(5, 1, 2, 3, 4), asList(1, 2, 3, 4, 5), 1);
		test(s, asList(5, 1, 2, 3, 4), asList(1, 2, 3, 4, 5), 6);
		test(s, asList(1, 2, 3, 4, 5), asList(1, 2, 3, 4, 5), 0);
	}

	private void test(Solution s, ListNode expected, ListNode input, int k) {
		assertEquals(expected, s.rotateRight(input, k));
	}
}
